package com.baidu.mapapi;

import android.app.Activity;
import android.content.Context;
import android.graphics.drawable.Drawable;
import android.util.DisplayMetrics;
import android.view.Display;
import android.view.WindowManager;
import android.widget.Toast;
import java.util.ArrayList;

public class PoiOverlay extends ItemizedOverlay<OverlayItem>
{
  private MapView a;
  private Context b;
  private int c;
  public ArrayList<MKPoiInfo> mList = null;

  public PoiOverlay(Activity paramActivity, MapView paramMapView)
  {
    super(null);
    this.a = null;
    this.b = null;
    this.c = 1;
    this.b = paramActivity;
    this.a = paramMapView;
    DisplayMetrics localDisplayMetrics = new DisplayMetrics();
    paramActivity.getWindowManager().getDefaultDisplay().getMetrics(localDisplayMetrics);
    if (Mj.i <= 120)
      this.c = 0;
    while (true)
    {
      while (true)
      {
        return;
        if (Mj.i > 180)
          break;
        this.c = 1;
      }
      this.c = 2;
    }
  }

  public void animateTo()
  {
    if (size() > 0)
      onTap(0);
  }

  protected OverlayItem createItem(int paramInt)
  {
    char[] arrayOfChar1 = new char[10];
    arrayOfChar1[0] = 97;
    arrayOfChar1[1] = 98;
    arrayOfChar1[2] = 99;
    arrayOfChar1[3] = 100;
    arrayOfChar1[4] = 101;
    arrayOfChar1[5] = 102;
    arrayOfChar1[6] = 103;
    arrayOfChar1[7] = 104;
    arrayOfChar1[8] = 105;
    arrayOfChar1[9] = 106;
    char[] arrayOfChar2 = new char[3];
    arrayOfChar2[0] = 108;
    arrayOfChar2[1] = 109;
    arrayOfChar2[2] = 104;
    MKPoiInfo localMKPoiInfo = (MKPoiInfo)this.mList.get(paramInt);
    OverlayItem localOverlayItem = new OverlayItem(localMKPoiInfo.pt, localMKPoiInfo.name, localMKPoiInfo.address);
    Drawable localDrawable = null;
    if (paramInt < 10)
    {
      StringBuilder localStringBuilder = new StringBuilder(32);
      localStringBuilder.append("icon_mark").append(arrayOfChar1[paramInt]).append('_').append(arrayOfChar2[this.c]).append(".png");
      localDrawable = i.a(this.b, localStringBuilder.toString());
    }
    localOverlayItem.setMarker(boundCenterBottom(localDrawable));
    return localOverlayItem;
  }

  public MKPoiInfo getPoi(int paramInt)
  {
    MKPoiInfo localMKPoiInfo;
    if (this.mList == null)
      localMKPoiInfo = null;
    while (true)
    {
      return localMKPoiInfo;
      localMKPoiInfo = (MKPoiInfo)this.mList.get(paramInt);
    }
  }

  protected boolean onTap(int paramInt)
  {
    OverlayItem localOverlayItem = getItem(paramInt);
    this.a.getController().animateTo(localOverlayItem.mPoint);
    if (localOverlayItem.mTitle != null)
      Toast.makeText(this.b, localOverlayItem.mTitle, 1).show();
    super.onTap(paramInt);
    return true;
  }

  public void setData(ArrayList<MKPoiInfo> paramArrayList)
  {
    if (paramArrayList != null)
    {
      this.mList = paramArrayList;
      super.populate();
    }
  }

  public int size()
  {
    int i;
    if (this.mList == null)
      i = 0;
    while (true)
    {
      while (true)
      {
        return i;
        if (this.mList.size() <= 10)
          break;
        i = 10;
      }
      i = this.mList.size();
    }
  }
}